<div class="header-login-form">
    <div class="title">
            <h3>Identificación</h3>
            
    </div>
    <form action="" method="post">
        <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
        <input class="oculto" type="checkbox" name="_remember_me" value="on" checked>
        <div class="espera oculto">
            {% image '@AmistateBundle/Resources/public/images/cargando.gif' %}
                <img src="{{ asset_url }}" alt="Cargando" title="Espere por favor."/>
            {% endimage %}
            Ingresando con su cuenta de facebook...
        </div>
        <div class="error invalid_user">
        </div>
        <div class="formRow">
            <label for="email">Email:</label>
            <input class="icon16 icon-mini-user" type="text" name="_username" id="email">
        </div>
        <div class="formRow">
            <label for="clave">Contraseña:</label>
            <input class="icon16 icon-mini-clave" type="password" name="_password" id="clave">
        </div>
        <div class="actions">
            <input type="submit" value="Entrar"/>
            <div class="facebook">
                <a class="login-facebook sp" href="javascript:void(0);" onclick="loginFacebook('{{facebook_appid}}','{{path}}');">&nbsp;</a>
            </div>
            <a href="{{ path('fos_user_resetting_request') }}">¿Olvidaste tu contraseña?</a>
            <a class="registrar" href="{{ url('fos_user_registration_register') }}">Registrate Ahora!</a>
        </div>
        
    </form>
    <script type="text/javascript">
            var login_validator = $('.header-login-form form').validate({
                    rules: {
                    _username: 'required email',
                    _password: 'required'
                },
                messages: {
                    _password: 'Por favor ingrese su clave',
                    _username: {
                        required: 'Por favor ingrese su e-mail',
                        _username: 'Por favor ingrese un e-mail v&aacute;lido'
                    }
                },
                submitHandler: function() {
                    $.ajax({
                            type: 'POST',
                            url: "{{ path('fos_user_security_check') }}",
                            data: $('.header-login-form form').serialize(),
                            dataType: 'json',
                            success: function(data) {
                                if(data.success == true){
                                    window.location.reload();
                                }else{
                                    $('.header-login-form form .invalid_user').html("Mail o contraseña no validos.");
                                    $('.header-login-form form .invalid_user').show();
                                }
                            }
                    });
                    return false;
                },
                invalidHandler: function(){
                }
            });
    </script>
</div>